package org.appmon.core.config;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;



public class TempTest {
	
	public void Test() {
		
		try {
	//		ClassLoader.getSystemClassLoader().loadClass("org.appmon.core.config.BehaviourProperties");
		 Class clas = ClassLoader.getSystemClassLoader().loadClass("org.appmon.core.config.PackageBaseInfo");
	//		 Class clas = Class.forName("org.appmon.core.config.PackageBaseInfo");
			Method main = clas.getMethod("getInstance", new Class[0]);
		 Object object=main.invoke(null, null);
		 System.out.println("Reflect obj : "+object.hashCode());
		 
		 Method m1=clas.getMethod("getPackageToInclude", new Class[0]);
		 Object object2=m1.invoke(object, null);
		 ConcurrentHashMap map = (ConcurrentHashMap)object2;
		 map.put("abc",new Object());
		 System.out.println("Havoc OBJ : "+map);
		 
//		 Class carg[]=new Class[1];
//		// carg[0]=String.class;
//		 carg[0]=Object.class;
//		 Class params[] = {Object.class};
//		 Object paramsObj[] = {new Object()};
//		 Object o=new Object();
//		 Method m2=clas.getMethod("setCounter", params);
//		 Object object3=m1.invoke(object,paramsObj);
		 

		 Field mapfeild = clas.getDeclaredField("packageToInclude");
		 mapfeild.setAccessible(true);
		 Map fieldValue = (ConcurrentHashMap)mapfeild.get(object);
		 fieldValue.put("test", new Object());
		 System.out.println("fieldValue = " + fieldValue);
		 System.out.println("Havoc OBJ : "+map);
		 
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		 
		
	}

}
